<template>
  <el-container class="layout-container-demo" style="height: 500px">
    <el-aside width="200px">
      <el-scrollbar>
        <el-menu
          active-text-color="#ffd04b"
          background-color="#545c64"
          class="el-menu-vertical-demo"
          default-active="2"
          text-color="#fff"
          @open="handleOpen"
          @close="handleClose"
          router
        >
          <el-menu-item index="/">
            <el-icon><icon-menu /></el-icon>
            <span>首页</span>
          </el-menu-item>
          <el-sub-menu index="/productList">
            <!-- 一级目录 -->
            <template #title>
              <el-icon>
                <location />
              </el-icon>
              <span>商品管理</span>
            </template>
            <!-- 二级目录 -->
            <el-menu-item index="/productList">商品列表</el-menu-item>
            <el-menu-item index="1-4">商品添加</el-menu-item>

            <!-- 三级目录 -->
            <!-- <el-sub-menu index="1-4">
              <template #title>item four</template>
              <el-menu-item index="1-4-1">item one</el-menu-item>
            </el-sub-menu> -->
          </el-sub-menu>

          <el-menu-item index="/tongji">
            <el-icon><icon-menu /></el-icon>
            <span>统计信息</span>
          </el-menu-item>
          <el-sub-menu index="/usermanager">
            <!-- 一级目录 -->
            <template #title>
              <el-icon>
                <location />
              </el-icon>
              <span>用户管理</span>
            </template>
            <!-- 二级目录 -->
            <el-menu-item index="/usermanager">用户列表</el-menu-item>
            <el-menu-item index="useradd">添加用户</el-menu-item>

          </el-sub-menu>
        </el-menu>
        
      </el-scrollbar>
    </el-aside>

    <el-container>
      <el-header style="text-align: right; font-size: 12px">
        <div class="toolbar">
          <el-dropdown>
            <el-icon style="margin-right: 8px; margin-top: 1px">
              <setting />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人设置</el-dropdown-item>
                <el-dropdown-item @click="$router.push('/login')">退出</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <span>Tom</span>
        </div>
      </el-header>

      <el-main>
        <el-scrollbar>
          <!-- 二级路由视图出口 -->
          <router-view></router-view>
        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>
import {  Menu as IconMenu, Location, Setting } from '@element-plus/icons-vue'
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
</script>

<style scoped>
.layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}

.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}

.layout-container-demo .el-menu {
  border-right: none;
}

.layout-container-demo .el-main {
  padding: 0;
}

.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
